<template>
  <div class="recommend">
    <div class="question">
      <div class="question-icon">问</div>
      <div class="question-title">抑郁症的原因</div>
    </div>
    <div class="question-content">
      <div class="question-description">
        抑郁症是一种疾病，不会轻易罹患抑郁症。发病的原因目前还不清楚，可能和遗传因素、社会...
      </div>
      <div class="author-info">
        <img src="https://u.miaoshoucdn.com/avatar/004/48/97/004489709_mid.jpg?v=17314587568343" alt="作者头像"
          class="author-avatar">
        <div class="author-name">万兴松 主任医师</div>
        <div class="read-count">7177 阅读</div>
      </div>
    </div>

  </div>

</template>

<script setup lang="ts">
import { essay } from '../../api/index'
import { ref } from 'vue'
interface essayData {
  id: string,
  texttitle: string,
  textdescword: string,
  texttype: string,
  textcount: number
}
// 定义一个响应式变量list，初始值为空数组
const list = ref<essayData[]>([])
// 定义一个异步函数getessay
const getessay = async () => {
    try {
        const res = await essay();
        list.value = res.data.slice(0, 10);
        // console.log(list.value);
    } catch (error) {
        console.log("请求出错:", error);
    }
};
getessay()
</script>

<style scoped>
/* 整体页面布局样式 */
body {
  font-family: Arial, sans - serif;
  margin: 0;
  padding: 0;
}

.recommend {
  width: 100%;
  height: 3rem;
  border-bottom: 1px solid #f4f5f6;
  /* background: green; */
  padding: 0.3rem 0.2rem 0.3rem 0.3rem;
}

/* 推荐标题样式 */
.recommend h2 {
  margin-top: 0;
}

/* 问题区域样式 */
.question {
  display: flex;
  align-items: center;
  margin-bottom: 0.3rem;
}

.question-content {
  width: 95%;
  margin-left: 0.25rem;
}

/* 问题图标样式 */
.question-icon {
  width: 0.4rem;
  height: 0.4rem;
  background-color: green;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  margin-right: 0.1rem;
  font-size: 0.25rem;
}

/* 问题标题样式 */
.question-title {
  font-size: 0.3rem;
}

/* 问题描述样式 */
.question-description {
  margin-bottom: 0.2rem;
  font-size: 0.25rem;
}

/* 作者信息样式 */
.author-info {
  display: flex;
  align-items: center;
}

/* 作者头像样式 */
.author-avatar {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin-right: 0.2rem;
}

/* 作者姓名和职称样式 */
.author-name {
  font-size: 0.25rem;
  margin-right: 2rem;
  color: #999999;
}

/* 阅读量样式 */
.read-count {
  color: #d6d6d6;
  font-size: 0.25rem;
  /* background: red; */
}
</style>